"""特征工程基础工具函数."""

from __future__ import annotations

import pandas as pd


def _ema(series: pd.Series, span: int) -> pd.Series:
    """计算指数移动平均（EMA）.
    
    Parameters
    ----------
    series:
        价格序列
    span:
        平滑周期
        
    Returns
    -------
    pd.Series
        EMA序列
    """
    return series.ewm(span=span, adjust=False).mean()


def _sma(series: pd.Series, window: int) -> pd.Series:
    """计算简单移动平均（SMA）.
    
    Parameters
    ----------
    series:
        价格序列
    window:
        窗口大小
        
    Returns
    -------
    pd.Series
        SMA序列
    """
    return series.rolling(window, min_periods=window).mean()


def _rolling_std(series: pd.Series, window: int) -> pd.Series:
    """计算滚动标准差.
    
    Parameters
    ----------
    series:
        价格序列
    window:
        窗口大小
        
    Returns
    -------
    pd.Series
        滚动标准差序列
    """
    return series.rolling(window, min_periods=window).std()

